/*
 *
 *      Copyright (c) 2018-2025, lengleng All rights reserved.
 *
 *  Redistribution and use in source and binary forms, with or without
 *  modification, are permitted provided that the following conditions are met:
 *
 * Redistributions of source code must retain the above copyright notice,
 *  this list of conditions and the following disclaimer.
 *  Redistributions in binary form must reproduce the above copyright
 *  notice, this list of conditions and the following disclaimer in the
 *  documentation and/or other materials provided with the distribution.
 *  Neither the name of the pig4cloud.com developer nor the names of its
 *  contributors may be used to endorse or promote products derived from
 *  this software without specific prior written permission.
 *  Author: lengleng (wangiegie@gmail.com)
 *
 */

package com.pig4cloud.pig.admin.api.entity;

import com.baomidou.mybatisplus.annotation.*;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.FieldNameConstants;

import java.time.LocalDateTime;

/**
 * 菜单权限表实体类
 * <p>
 * 系统菜单和按钮权限管理，支持树形结构的菜单层级。
 * 菜单包含前端路由信息、权限标识等，用于构建前端导航和权限控制
 * </p>
 *
 * @author lengleng
 * @since 2017-11-08
 */
@Data
@Schema(description = "菜单")
@FieldNameConstants
@EqualsAndHashCode(callSuper = true)
public class SysMenu extends Model<SysMenu> {

	private static final long serialVersionUID = 1L;

	/**
	 * 菜单ID
	 * <p>
	 * 主键，采用雪花算法生成的唯一标识
	 * </p>
	 */
	@TableId(value = "menu_id", type = IdType.ASSIGN_ID)
	@Schema(description = "菜单id")
	private Long menuId;

	/**
	 * 菜单名称
	 * <p>
	 * 菜单的中文显示名称，用于前端展示
	 * </p>
	 */
	@NotBlank(message = "菜单名称不能为空")
	@Schema(description = "菜单名称")
	private String name;

	/**
	 * 菜单英文名称
	 * <p>
	 * 菜单的英文名称，用于国际化场景
	 * </p>
	 */
	@Schema(description = "菜单名称")
	private String enName;

	/**
	 * 菜单权限标识
	 * <p>
	 * 权限标识字符串，格式通常为"sys:资源:操作"，
	 * 如sys_user_add、sys_role_edit等，用于后端权限控制
	 * </p>
	 */
	@Schema(description = "菜单权限标识")
	private String permission;

	/**
	 * 父菜单ID
	 * <p>
	 * 指向父级菜单的ID，顶级菜单的父ID为-1
	 * </p>
	 */
	@NotNull(message = "菜单父ID不能为空")
	@Schema(description = "菜单父id")
	private Long parentId;

	/**
	 * 图标
	 * <p>
	 * 菜单图标类名，支持各种图标库（如Ant Design Icons）
	 * </p>
	 */
	@Schema(description = "菜单图标")
	private String icon;

	/**
	 * 前端路由标识路径
	 * <p>
	 * 前端路由的path值，用于匹配路由组件。
	 * 默认和comment保持一致（已过期）
	 * </p>
	 */
	@Schema(description = "前端路由标识路径")
	private String path;

	/**
	 * 菜单显示隐藏控制
	 * <p>
	 * 0-显示，1-隐藏。控制菜单在前端是否显示
	 * </p>
	 */
	@Schema(description = "菜单是否显示")
	private String visible;

	/**
	 * 排序值
	 * <p>
	 * 用于控制同级菜单的显示顺序，数值越小越靠前
	 * </p>
	 */
	@Schema(description = "排序值")
	private Integer sortOrder;

	/**
	 * 菜单类型
	 * <p>
	 * 0-菜单：显示在导航中的菜单项
	 * 1-按钮：页面内的权限按钮，不显示在导航中
	 * </p>
	 */
	@NotNull(message = "菜单类型不能为空")
	@Schema(description = "菜单类型,0:菜单 1:按钮")
	private String menuType;

	/**
	 * 路由缓冲
	 * <p>
	 * 0-不缓存，1-缓存。控制Vue组件是否使用keep-alive缓存
	 * </p>
	 */
	@Schema(description = "路由缓冲")
	private String keepAlive;

	/**
	 * 菜单是否内嵌
	 * <p>
	 * 0-非内嵌，1-内嵌。控制是否在iframe中打开外部链接
	 * </p>
	 */
	@Schema(description = "菜单是否内嵌")
	private String embedded;

	/**
	 * 创建人
	 */
	@TableField(fill = FieldFill.INSERT)
	@Schema(description = "创建人")
	private String createBy;

	/**
	 * 修改人
	 */
	@TableField(fill = FieldFill.UPDATE)
	@Schema(description = "修改人")
	private String updateBy;

	/**
	 * 创建时间
	 */
	@TableField(fill = FieldFill.INSERT)
	@Schema(description = "创建时间")
	private LocalDateTime createTime;

	/**
	 * 更新时间
	 */
	@TableField(fill = FieldFill.UPDATE)
	@Schema(description = "更新时间")
	private LocalDateTime updateTime;

	/**
	 * 删除标记
	 * <p>
	 * 逻辑删除标记，0-正常，1-已删除
	 * </p>
	 */
	@TableLogic
	@TableField(fill = FieldFill.INSERT)
	@Schema(description = "删除标记,1:已删除,0:正常")
	private String delFlag;

}
